import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Component({
  selector: 'app-myc01',
  templateUrl: './myc01.component.html',
  styleUrls: ['./myc01.component.css'],
})
export class Myc01Component {
  // 首先要在构造方法中声明依赖，然后
  constructor(public http: HttpClient) {}

  ngOnInit(): void {
    // 还记得axios吗，axios.get(url).then(res=>{...})
    // angular里面换了个词而已，不过结果要用subscribe来接受
    this.http.get('http://localhost:10086').subscribe((res) => {
      console.log(res);
    });
  }
}
